﻿using Microsoft.EntityFrameworkCore;
using Project.DTO;
using Project.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Project.Service
{
    public partial class WebUserService
    {
        public async Task<UserDto> GetUserDtoAsync(Guid id)
        {
             return await baseRepostory.Find<WebUser>(e => e.Id == id)
                .Select(e => mapper.Map<UserDto>(e)).FirstOrDefaultAsync();
        }

        public async Task<UserDto> CheckIdentity(string phone,string pwd)
        {
            return await baseRepostory.Find<WebUser>(e => e.Phone == phone && e.LoginPwd == pwd)
                .Select(e => mapper.Map<UserDto>(e)).FirstOrDefaultAsync();
        }

        public async Task<Guid> GetUserIdByPhone(string phone)
        {
            return await baseRepostory.Find<WebUser>(e => e.Phone == phone && e.IsDeleted == false).Select(n => n.Id).FirstOrDefaultAsync();
        }
    }
}
